package online.sh.cn.fy.servlet;

import java.io.IOException;
import java.net.URLDecoder;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;
import online.sh.cn.fy.common.utils.SqlUtil;

/**
 * Servlet implementation class fycaptionCall
 */
@WebServlet("/fycaptionCall")
public class fycaptionCall extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public fycaptionCall() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		String school = URLDecoder.decode(request.getParameter("school"),"UTF-8");
		String area = URLDecoder.decode(request.getParameter("area"),"UTF-8");
		String building = URLDecoder.decode(request.getParameter("building"),"UTF-8");
		SqlUtil sqlutil= new SqlUtil();
		Map<String,String> result= sqlutil.getfyCaption(school, area, building);
       
        session.setAttribute("cpname", result.get("cpname"));
        session.setAttribute("cplevel", result.get("cplevel"));
        session.setAttribute("cpqq", result.get("cpqq"));
        session.setAttribute("cpmobile", result.get("cpmobile"));
        session.setAttribute("cpwechat", result.get("cpwechat"));
        
        response.sendRedirect("./call.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
